﻿@using Models
@model List<Users>
@{
    var cookie = Request.Cookies[FormsAuthentication.FormsCookieName];
    FormsAuthenticationTicket auth = null;
    if (cookie != null)
    {
        auth = FormsAuthentication.Decrypt(cookie.Value);

        ViewBag.auth = auth;
    }
    ViewBag.Title = "All users";
}

 @Html.Partial("_openDialog")

<div style="float: left; height: 70px"><a href="/admin/index" ><img src="/Content/images/back.png" /></a></div>
<div style="margin-left: 80px;"><a href="/admin/AddUser" ><img src="/content/images/user_add.png" alt="Add User" /><br />Add User</a></div>
<h2>All users</h2>

<!--Html.Partial("_filter_users")!-->

<table id="table_admin">
    
    <tr>
        <td>
            @Html.ActionLink("Id", "AllUsers", "Admin", new { page = ViewBag.pager.CurrentPage, orderBy = "id" }, null)   
        </td>
        <td>
            @Html.ActionLink("Login", "AllUsers", "Admin", new { page = ViewBag.pager.CurrentPage, orderBy = "login" }, null)
        </td>
        <td>
            @Html.ActionLink("Email", "AllUsers", "Admin", new { page = ViewBag.pager.CurrentPage, orderBy = "email" }, null)
        </td>
        <td>
            @Html.ActionLink("Role", "AllUsers", "Admin", new { page = ViewBag.pager.CurrentPage, orderBy = "role" }, null)
        </td>
        <td>
            @Html.ActionLink("Name", "AllUsers", "Admin", new { page = ViewBag.pager.CurrentPage, orderBy = "name" }, null)
        </td>
        <td>
            @Html.ActionLink("Last", "AllUsers", "Admin", new { page = ViewBag.pager.CurrentPage, orderBy = "fName" }, null)
        </td>
        <td>
            @Html.ActionLink("Middle", "AllUsers", "Admin", new { page = ViewBag.pager.CurrentPage, orderBy = "mName" }, null)
        </td>
        <td>
            Action button
        </td>
    </tr>

    @{
        for (int i = ViewBag.pager.StartIndex - 1; i < ViewBag.pager.EndIndex;i++ )
        {
            <tr>
                <td>
                    @Model[i].Id
                </td>
                <th>
                    @Model[i].Login
                </th>
                <td>
                    @Model[i].Email
                </td>
                <th>
                    @Model[i].Role
                </th>
                <td>
                    @Model[i].Name
                </td>
                <th>
                    @Model[i].FName
                </th>
                <td>
                    @Model[i].MName
                </td>
                <th>
                    <a href="/Admin/UpdateUser/@Model[i].Id"><img src="/content/images/Refresh.png" alt="Update" /></a>

                    
                    @if (auth.UserData == "1")
                    {
                        int id = @Model[i].Id;
                        <a href="/admin/DeleteUser/@Model[i].Id" onmousedown="return openDialog('@id','/Admin/DeleteUser');"><img src="/content/images/Delete.png" alt="Delete" /></a>
                    }
                </th>
            </tr>
        
           
        }
    }
</table>
